home *** CD-ROM | disk | FTP | other *** search
- Path: watnews.watson.ibm.com!kgold
- From: kgold@watson.ibm.com (K Goldman)
- Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
- Subject: Re: Seek unix2dos.c OR help with tr
- Date: 11 Mar 1996 15:15:43 GMT
- Organization: IBM T.J. Watson Research Center
- Distribution: ibm
- Message-ID: <4i1g2v$m12@watnews1.watson.ibm.com>
- References: <4i0946$7io@nuke.csu.net>
- NNTP-Posting-Host: beta.watson.ibm.com
-
- mclean@futon.SFSU.EDU (Emmett Mclean) writes:
- |>
- |> Does anyone have the source to a program
- |> converting a unix file into dos format?
- |> That is, each decimal 10 char is replaced
- |> with a series of a 10 and 13.
- |>
- |>[snip]
- |>
- |> I will be using it to download zipped binaries
- |> files from a unix box.
- |>
- |> Ah, writing the program is a bit trickier
- |> than the little program below since the
- |> program exits prematurely because getchar reads
- |> EOF from its input - before getting to
- |> the real EOF.
- |>
- |> #include <stdio.h>
- |> main(){
- |> char c;
- |> while(EOF!=(c=getchar())){
- |> if(10==c)putchar(13);
- |> putchar(c);
- |> }
- |> putchar(10);
- |> }
- |>
-
- The tricky part is that getchar() returns an int, not a char.
- It does that so EOF does not collide with a legal 8 bit char.
-
- BTW, if you're using an AIX machine, aix2dos and dos2aix are
- included and do exactly what you want.
-
- --
- Ken Goldman kgold@watson.ibm.com 914-784-7396
-